import 'package:flutter/material.dart';

void main() {
  runApp(const _MyApp());
}

class _MyApp extends StatelessWidget {
  const _MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Container",
      theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
          useMaterial3: true),
      home: const _MyHomePage(),
    );
  }
}

class _MyHomePage extends StatefulWidget {
  const _MyHomePage({super.key});

  // @override
  // State<StatefulWidget> createState() => _MyHomePageState();

  @override
  State<StatefulWidget> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<_MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Container Demo"),
      ),
      body: Container(
        // 设置上边距 左边距
        margin: const EdgeInsets.only(top: 60.0, left: 100.0),
        // 约束
        constraints: const BoxConstraints.tightFor(width: 300.0, height: 150.0),
        decoration: BoxDecoration(
            // 添加渐变色
            border: Border.all(width: 3, color: const Color(0xffaaaaaa)),
            boxShadow: const [
              // 添加盒子阴影
              BoxShadow(
                  color: Colors.black54,
                  offset: Offset(2.0, 2.0),
                  blurRadius: 4.0)
            ],
            // 添加渐变色
            gradient: const LinearGradient(
                colors: [Colors.red, Colors.blue, Colors.green])),
        // 整个 container 旋转
        transform: Matrix4.rotationZ(.3),
        // 对于其中文本的摆放位置
        alignment: Alignment.center,
        child: const Text(
          "Container",
          style: TextStyle(color: Colors.white, fontSize: 30),
        ),
      ),
    );
  }
}
